package com.copc.common.util;

import cn.hutool.core.util.IdcardUtil;

/**
 * 根据身份证号获取性别
 * @author yuni
 * @since 2023/3/10 10:15
 */
public class IdcardPicusUtils {
    public static String getSexFromIdCard(String idCard) {
        if (idCard.length() != 18 && idCard.length() != 15) {
            return "请输入正确的身份证号码";
        }
        if (idCard.length() == 18) {

        } else if (idCard.length() == 15) {
            idCard = IdcardUtil.convert15To18(idCard);
        }

        return IdcardUtil.getGenderByIdCard(idCard)==1?"M":"F";
    }
}
